package dhz.tools.util;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import org.apache.log4j.Logger;

public class IOUtils {

	private static final Logger LOG = Logger.getLogger(IOUtils.class);
	
	private IOUtils(){
	}
	
	public static void closeIs(InputStream is){
		if(is != null){
			try {
				is.close();
			} catch (Exception e) {
				LOG.error("流关闭出错",e);
			}
		}
	}
	
	public static void closeOs(OutputStream os){
		if(os != null){
			try {
				os.close();
			} catch (Exception e) {
				LOG.error("流关闭出错",e);
			}
		}
	}
	
	public static void closeWriter(Writer writer){
		try {
			if(writer != null){
				writer.close();
			}
		} catch (Exception e) {
			LOG.error("流关闭出错",e);
		}
	}
	
	public static void closeReader(Reader reader){
		try {
			if(reader != null){
				reader.close();
			}
		} catch (Exception e) {
			LOG.error("流关闭出错",e);
		}
	}
	
}
